package com.kanqiubao.kq.fragment.main;

import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.listener.OnItemClickListener;
import com.jay.widget.StickyHeadersLinearLayoutManager;
import com.kanqiubao.kq.R;
import com.kanqiubao.kq.activity.live.LiveDetailActivity;
import com.kanqiubao.kq.adapter.main.MainOneListAdapter;
import com.kanqiubao.kq.bean.main.MainOneListBean;
import com.kanqiubao.kq.fragment.BaseFragment;
import com.scwang.smart.refresh.layout.SmartRefreshLayout;

import java.util.ArrayList;
import java.util.List;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

public class MainListFragment extends BaseFragment<String> implements OnItemClickListener {

    private MainOneListAdapter mMainOneListAdapter;
    protected RecyclerView mRecyclerView;
    protected SmartRefreshLayout mSmartRefreshLayout;
    @Override
    protected int getLayoutId() {
        return R.layout.include_smart_recycler_refresh_layout;
    }

    @Override
    protected void initData() {
        List<MainOneListBean> ls=new ArrayList<>();
        ls.add(new MainOneListBean(MainOneListBean.GROUP));
        ls.add(new MainOneListBean(MainOneListBean.ITEM));
        ls.add(new MainOneListBean(MainOneListBean.ITEM));
        ls.add(new MainOneListBean(MainOneListBean.ITEM));
        ls.add(new MainOneListBean(MainOneListBean.ITEM));
        ls.add(new MainOneListBean(MainOneListBean.GROUP));
        ls.add(new MainOneListBean(MainOneListBean.ITEM));
        ls.add(new MainOneListBean(MainOneListBean.ITEM));
        ls.add(new MainOneListBean(MainOneListBean.ITEM));
        ls.add(new MainOneListBean(MainOneListBean.ITEM));
        ls.add(new MainOneListBean(MainOneListBean.ITEM));
        ls.add(new MainOneListBean(MainOneListBean.ITEM));
        ls.add(new MainOneListBean(MainOneListBean.GROUP));
        ls.add(new MainOneListBean(MainOneListBean.ITEM));
        ls.add(new MainOneListBean(MainOneListBean.ITEM));
        ls.add(new MainOneListBean(MainOneListBean.ITEM));
        ls.add(new MainOneListBean(MainOneListBean.ITEM));
        ls.add(new MainOneListBean(MainOneListBean.ITEM));
        ls.add(new MainOneListBean(MainOneListBean.ITEM));
        ls.add(new MainOneListBean(MainOneListBean.ITEM));
        ls.add(new MainOneListBean(MainOneListBean.ITEM));
        ls.add(new MainOneListBean(MainOneListBean.ITEM));
        ls.add(new MainOneListBean(MainOneListBean.ITEM));
        mMainOneListAdapter.addData(ls);
    }

    @Override
    protected void initView() {
        mRecyclerView=findView(R.id.recyclerView);
        mSmartRefreshLayout=findView(R.id.refreshLayout);
        mMainOneListAdapter = new MainOneListAdapter();
        StickyHeadersLinearLayoutManager<MainOneListAdapter> layoutManager = new StickyHeadersLinearLayoutManager<>(getAppBaseActivity());
        mRecyclerView.setLayoutManager(layoutManager);
        mRecyclerView.setAdapter(mMainOneListAdapter);
        mMainOneListAdapter.setOnItemClickListener(this);

    }

    @Override
    public void onItemClick(@NonNull BaseQuickAdapter<?, ?> adapter, @NonNull View view, int position) {
        startMyActivity(LiveDetailActivity.class);
    }
}